package com.braveman.im.ui.activity.message;

import android.view.Gravity;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.TextView;

import com.braveman.im.R;
import com.braveman.im.ui.weiget.ButtonItem;
import com.braveman.im.ui.weiget.CustomPopwindow;
import com.braveman.im.ui.weiget.DialogUtils;
import com.braveman.im.ui.weiget.UISwitchButton;
import com.braveman.im.utils.UtilsStyle;
import com.ht.baselibs.ui.base.BaseActivity;
import com.ht.baselibs.utils.ActivityUtils;
import com.ht.baselibs.utils.UIUtils;
import com.vondear.rxtools.RxBarTool;


public class CompanyManagerActivity extends BaseActivity {
    private ButtonItem mBtiActivityCompanyEdit;
    private ButtonItem mBtiActivityCompanyJoinStates;
    private ButtonItem mBtiActivityCompanyGiveOther;
    private ButtonItem mBtiActivityCompanyInviteStates;
    private UISwitchButton mSwBtnActivityCompanyCanInvite;
    private ButtonItem mBtiActivityCompanyManagerSetting;
    private ButtonItem mBtiActivityCompanyCheck;
    private TextView mTvNumHint;


    @Override
    protected boolean isStaticPage() {
        return true;
    }

    @Override
    protected void initTitleBar() {
        mTitleBarView.setTitleText("管理单位").setLeftBtnIcon(R.mipmap.back_black).setOnLeftBtnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ActivityUtils.finishActivity(CompanyManagerActivity.this);
            }
        });
    }

    @Override
    protected int initContentView() {
        UtilsStyle.setStatusBarMode(this, true);
        RxBarTool.FlymeSetStatusBarLightMode(getWindow(), true);
        RxBarTool.MIUISetStatusBarLightMode(getWindow(), true);
        return R.layout.activity_compand_manager;
    }

    @Override
    protected void initChildView() {
        mBtiActivityCompanyEdit = (ButtonItem) findViewById(R.id.bti_activity_company_edit);
        mBtiActivityCompanyJoinStates = (ButtonItem) findViewById(R.id.bti_activity_company_join_states);
        mBtiActivityCompanyGiveOther = (ButtonItem) findViewById(R.id.bti_activity_company_give_other);
        mBtiActivityCompanyInviteStates = (ButtonItem) findViewById(R.id.bti_activity_company_invite_states);
        mSwBtnActivityCompanyCanInvite = (UISwitchButton) findViewById(R.id.sw_btn_activity_company_can_invite);
        mBtiActivityCompanyManagerSetting = (ButtonItem) findViewById(R.id.bti_activity_company_manager_setting);
        mBtiActivityCompanyCheck = (ButtonItem) findViewById(R.id.bti_activity_company_check);
        mTvNumHint = (TextView) findViewById(R.id.tv_num_hint);
    }

    @Override
    protected void initChildData() {

    }

    @Override
    protected void setChildViewListener() {
        mBtiActivityCompanyEdit.setOnClickListener(this);
        mBtiActivityCompanyJoinStates.setOnClickListener(this);
        mBtiActivityCompanyGiveOther.setOnClickListener(this);
        mBtiActivityCompanyInviteStates.setOnClickListener(this);
        mBtiActivityCompanyManagerSetting.setOnClickListener(this);
        mBtiActivityCompanyCheck.setOnClickListener(this);
        mSwBtnActivityCompanyCanInvite.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                UIUtils.showToast(b ? "不允许群成员邀请好友入群" : "允许群成员邀请好友入群");

            }
        });

    }


    @Override
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId()) {
            case R.id.bti_activity_company_edit:
                ActivityUtils.startActivity(this, EditCompanyInfoActivity.class);
                break;
            case R.id.bti_activity_company_join_states:
                DialogUtils.createPopwindow(this, "选择加入单位方式", "取消", new CustomPopwindow.OnBtnClickListener("允许任何人加单位") {
                    @Override
                    public void onClick(CustomPopwindow popwindow, View view) {

                        mBtiActivityCompanyJoinStates.tv_title_del.setText("允许任何人加单位");
                    }
                }, new CustomPopwindow.OnBtnClickListener("只需要身份验证") {
                    @Override
                    public void onClick(CustomPopwindow popwindow, View view) {
                        mBtiActivityCompanyJoinStates.tv_title_del.setText("只需要身份验证");
                    }
                }, new CustomPopwindow.OnBtnClickListener("只允许群成员邀请加单位") {
                    @Override
                    public void onClick(CustomPopwindow popwindow, View view) {
                        mBtiActivityCompanyJoinStates.tv_title_del.setText("只允许群成员邀请加单位");
                    }
                }, new CustomPopwindow.OnBtnClickListener("不允许任何人加单位") {
                    @Override
                    public void onClick(CustomPopwindow popwindow, View view) {
                        mBtiActivityCompanyJoinStates.tv_title_del.setText("不允许任何人加单位");
                    }
                }).showAtLocation(mBtiActivityCompanyJoinStates, Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM, 0, 130);
                break;
            case R.id.bti_activity_company_check:
//                ActivityUtils.startActivity(this, CompanyCheckActivity.class);
                break;
        }
    }

}
